package com.admgt.resource.ui;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.test.context.ContextConfiguration;

import com.admgt.resource.dao.LoadingInfoDao;
import com.admgt.resource.dao.LoadingInfoDaoImpl;
import com.admgt.resource.service.ResourceService;
import com.admgt.resource.service.ResourceServiceImpl;

@ContextConfiguration({"/app-config.xml"})
public class Launcher {
	private  LoadingInfoDao loadingInfoDao;
	
	@Autowired
	 public LoadingInfoDao getLoadingInfoDao() {
		return loadingInfoDao;
	}
	@Autowired
	public void setLoadingInfoDao(LoadingInfoDao loadingInfoDao) {
		this.loadingInfoDao = loadingInfoDao;
	}

	public void launch(){
         String contextPath[]=new String[]{"/app-config.xml"};
       //  new ClassPathXmlApplicationContext(contextPath);
         
         ApplicationContext appContext = 
     		new ClassPathXmlApplicationContext(contextPath);
 	
         ResourceService resourceService = new ResourceServiceImpl();
         LoadingInfoDao loadingInfoDao = (LoadingInfoDao)appContext.getBean("loadingInfoDao");
 		resourceService.setLoadingInfoDao(loadingInfoDao);
 		ResourceFrame resourceFrame = new ResourceFrame();
 		ResourceContext resourceContext = new ResourceContext();
 		resourceContext.setResourceFrame(resourceFrame);
 		resourceContext.setResourceService(resourceService);
 		resourceFrame.setResourceContext(resourceContext);
 		resourceContext.show();
  }
}
